import Controller from "./Controller";
import {Request,Response} from 'express';
class Setting extends Controller {

    constructor(req?:Request,res?:Response) {
        super(req,res);
    }

    /**
     * 获取系统参数配置
     */
    async get() {
        const data = await this.first("setting")
        if(!data) {
            await this.insert("setting",{
                weixin_tool_path: ""
            })
            this.get() 
            return false
        }
        this.response(200,data)
    }
 
    /**
     * 设置系统配置
     */
    async set() 
    {
        const data = await this.first("setting") as {id:number}
        const result = await this.update("setting",{id:data.id},this.HD)
        if(result) {
            this.response(200)
        } else {
            this.response(402,{},"设置失败")
        }   
    }
}

export default Setting